package com.lsl.abstract_factory.listfactory;

import com.lsl.abstract_factory.factory.Tray;

import java.util.Iterator;

/**
 * @author Zed
 * @description
 * @date 2022/11/27 18:30
 */
public class ListTray extends Tray {
    public ListTray(String caption) {
        super(caption);
    }

    @Override
    public String makeHTML() {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("<li>\n");
        stringBuffer.append(caption + "\n");
        stringBuffer.append("<ul>\n");
        Iterator iterator = trayList.iterator();
        while (iterator.hasNext()) {
            com.lsl.abstract_factory.factory.Item item = (com.lsl.abstract_factory.factory.Item) iterator.next();
            stringBuffer.append(item.makeHTML());
        }
        stringBuffer.append("</ul>\n");
        stringBuffer.append("</li>\n");
        return stringBuffer.toString();
    }
}
